package comp4081.java.hibernate;


/*import java.sql.Date;
import java.util.List;
import java.util.Set;
import java.util.Vector;*/
import java.util.*;

/*import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;*/
import javax.persistence.*;

import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.annotations.*;
import org.hibernate.tool.hbm2ddl.*;


@Entity
@Table (name="RTCANCER_TYPE", schema="test")
public class RightManyCancerType{
	private Long id;
	private String name;
	//List<LeftManyPatient> patient = new Vector();
	private Set<LeftManyPatient> patient = new HashSet<LeftManyPatient>();

	//Join table: DIAGNOSE
	@ManyToMany
	@JoinTable(name = "DIAGNOSE", joinColumns = { @JoinColumn(name="RMCANCER_TYPE_ID")}, 
	inverseJoinColumns = {@JoinColumn(name = "LMPATIENT_ID")}
	)
	/*private Long joinId;
	@Id
	@GeneratedValue
	@Column (name="ID")
	public Long getJoinId(){
		return joinId;
	}
	public void setJoinId(Long joinId){
		this.joinId = joinId;
	}	*/
	
	public Set<LeftManyPatient> getPatient(){
		return patient;
	}
	public void setPatient (Set<LeftManyPatient> lefties){
		this.patient = lefties;
	}
	
	@Id
	@GeneratedValue
	@Column (name="ID")
	public Long getId(){
		return id;
	}
	public void setId(Long id){
		this.id = id;
	}
	@Column (name="NAME")
	public String getName(){
		return name;
	}
	
	@Column (name="NAME")
	public void setName(String name){
		this.name = name;
	}

	
	
	public static void main(String[] args){
		//create a configuration object, reading from the hibernate.cf.xml file
		//Configuration config = new Configuration();
		Configuration config = new Configuration();
		//make sure hibernate aware of the User class
		config.addAnnotatedClass(RightManyCancerType.class);
		//read and process hibernate.cfg.xml and JPA metadata
		config.configure();
		new SchemaExport(config).create(true,true);
	    
	}
}